﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Stonecode.Solar.ParticleEffectEditor
{
    public partial class newEmitterForm : Form
    {
        public bool canceled = false;
        public string EmitterName = "";
        public uint ParticleCount = 0;
        public float ParticleRate = 0f;
        public ParticleEngine.Emitters.EmitterType EmitterType;
        public MainForm myParent;
        public newEmitterForm()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            canceled = true;
            this.Hide();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (txtEmitterName.Text == "")
            {
                MessageBox.Show("You must specify an emitter name");
                return;
            }
            if (numboxParticleCount.Value == 0)
            {
                MessageBox.Show("You must specify a particle count greater than zero");
                return;
            }
            if (numBoxParticleRate.Value == 0)
            {
                MessageBox.Show("You must specify a particle rate greater than zero");
                return;
            }
            if (cmboEmitterType.SelectedItem == null || cmboEmitterType.SelectedIndex == -1)
            {
                MessageBox.Show("You must specify an emitter type");
                return;
            }

            EmitterName = txtEmitterName.Text;
            ParticleCount = (uint)numboxParticleCount.Value;
            ParticleRate = (float)numBoxParticleRate.Value;
            EmitterType =  (Stonecode.Solar.ParticleEngine.Emitters.EmitterType)cmboEmitterType.SelectedItem;



            //this.Hide();
            this.Close();
            myParent.Activate();
            myParent.BringToFront();
        }

        private void newEmitterForm_Load(object sender, EventArgs e)
        {
            foreach (ParticleEngine.Emitters.EmitterType et in Enum.GetValues(typeof(ParticleEngine.Emitters.EmitterType)))
            {
                cmboEmitterType.Items.Add(et);
            }

            Point p = Cursor.Position;
            p.X -= this.Width/2;
            this.Location = p;
        }
    }
}
